/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bankapp.model;

import framework.model.Constant;
import framework.model.Customer;
import framework.model.Entry;

/**
 *
 * @author ThanhNguyen
 */
public class SavingAccount extends BankAccount {

    public SavingAccount(Customer customer) {
        super(customer);
        interestRate = Constant.SAVING_INTEREST_RATE;
    }

    @Override
    public String toString() {
        //return "S";
        return Constant.BANK_TYPE_SAVING;
    }
    @Override
    public String createNotification(Entry e) {
        if (customer.getType().equals(Constant.CTYPE_COMPANY)) {
            if (Math.abs(e.getAmount()) > Constant.COMPANY_SAVING_LIMIT) {
                return "Transaction amount greater than " + Constant.COMPANY_SAVING_LIMIT;
            }
        } else if (customer.getType().equals(Constant.CTYPE_PERSONAL)) {
            if (Math.abs(e.getAmount()) > Constant.PERSONAL_CHECKING_LIMIT) {
                return "Transaction amount greater than " + Constant.PERSONAL_CHECKING_LIMIT;
            }             
        }
        if (getCurrentBalance() < 0) {
            return "Current balance less than 0";
        }        
        return "Transaction is executed";
    }    
}
